<template>
  <view class="">
    <view class="feedback-box" v-if="IDcheck">
        <view class="fktitle2">姓名</view>
        <input v-model="username" class="lxfs-input" maxlength="11" placeholder="请输入姓名" 	 />
        <view class="fktitle2">身份证号码</view>  
          <view class="">
            <input v-model="IDcard" class="lxfs-input"  placeholder="请输入身份证号码" />
          </view>
        <view class="fktitle2">联系方式</view>  
          <input v-model="relation" class="lxfs-input" maxlength="11" type="number" placeholder="请输入手机号码" />
        <button class="fkbtn" @click="feedback">立即提交</button>
        <view class="" style="margin-top: 20rpx;color: red;" v-if="reject">
          驳回原因：{{cause}}
        </view>
    </view>
   <view style="width: 100%;text-align: center;font-size: 35rpx;margin-top: 70rpx;color: #4193FE;" v-else-if='pass'>
     审核通过！
   </view>
    <view style="width: 100%;text-align: center;font-size: 35rpx;margin-top: 70rpx;" v-else>
        已提交审核请耐心等待！
    </view>
    
   
    
  </view>
</template>

<script>
  export default {
    onLoad() {
      this.getstatus()
    },
    data() {
      return {
        fktxt:'',
        fktype:'客服',
        relation:'',
        IDcard:'',
        username:'',
        IDcheck:true,
        pass:false,
        cause:'',
        reject:false
    
      }
    },
    methods:{
      	radioChange(e) {
            this.fktype = e.detail.value
         	},
          getstatus() {
            uni.request({
            	url: getApp().globalData.apiDomain+'userauth/status',
            	method: 'POST',
            	header: {
            		'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
            		'token': uni.getStorageSync('wbyun_token'),
                'wbapp':'weixin_mp_xbgy'
            	},
               data:{ },
            	dataType: 'json',
            	success:  res => {
                console.log(res);
            		if (res['data']['code'] == 200) {
                  console.log(res);
                 
                  if(res['data']['datas']['status'] == 0) {
                    this.IDcheck = true
                  }else if(res['data']['datas']['status'] == 2) {
                    this.reject = true
                    this.cause = res['data']['datas']['memo'] 
                    this.IDcheck = true
                  }else if(res['data']['datas']['status'] == 3) {
                    this.IDcheck = false
                  }if(res['data']['datas']['status'] == 1) {
                    this.pass = true
                    this.IDcheck = false
                    
                  }
                  uni.showToast({
                    title: res['data']['datas']['msg'],
                    icon: 'none',
                    duration: 3500
                  });
           
            			return;
            		} else { 
            			uni.showToast({
            				title: res['data']['msg'],
            				icon: 'none'
            			});
            		}
            	},
            	fail: () => {},
            	complete: () => {
            	}
            });
          },
      feedback() {
      this.username =  this.username.replace(/\s+/g,'')
      this.IDcard =  this.IDcard.replace(/\s+/g,'')
      this.relation =  this.relation.replace(/\s+/g,'')
      if(this.username == '' || this.IDcard == ''||this.relation == '') {
        uni.showToast({
          title: '必填项不能为空!',
          icon: 'none'
        });
        return
      }
            const regex = /^1[3-9]\d{9}$/; // 中国大陆手机号正则表达式
            if (!regex.test(this.relation)) {
                uni.showToast({
                  title: '请输入有效的手机号!',
                  icon: 'none'
                });
                return
            }
            
            const idCardReg = /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/;
           
           if (!idCardReg.test(this.IDcard)) {
               uni.showToast({
                 title: '请输入有效的身份证号码!',
                 icon: 'none'
               });
               return
           }

  
        uni.request({
        	url: getApp().globalData.apiDomain+'/userauth/update',
        	method: 'POST',
        	header: {
        		'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
        		'token': uni.getStorageSync('wbyun_token'),
            'wbapp':'weixin_mp_xbgy'
        	},
           data:{
             'name':this.username,
             'idcard':this.IDcard,
             'tel':this.relation
           },
        	dataType: 'json',
        	success:  res => {
            console.log(res);
        		if (res['data']['code'] == 200) {
              uni.showToast({
                title: res['data']['msg'],
                icon: 'none',
                duration: 3500
              });
              this.getstatus()
              // this.IDcheck = false
              this.IDcard = ''
              this.relation =''
              this.username = ''
        			return;
        		} else { 
        			uni.showToast({
        				title: res['data']['msg'],
        				icon: 'none'
        			});
        		}
        	},
        	fail: () => {},
        	complete: () => {
        	}
        });
      }
    }
  }
</script>

<style>
  .feedback-box {
    width: 92%;
    padding: 55rpx;
    height: 1000rpx;
    margin: 30rpx auto 0 auto;
    
    background-color: #fff;
    border-radius: 15rpx;
  }
  radio::before,
  checkbox::before {
    z-index: 0;
    
  }
  checkbox .wx-checkbox-input::before,
  radio .wx-radio-input::before {
    display: block;
    /* background-color: rgb(3,188,191); */
  }
radio .wx-radio-input.wx-radio-input-checked {
		background-color: #4193FE !important;
    border: 0;
		color: #ffffff !important;
	}
  radio {
    margin-right: 10rpx;
  }
.fktitle,.fktitle2 {
  font-size: 36rpx;
  color: #a3a3a3;
}
.fktitle2 {
  margin: 45rpx 0 30rpx 0;
}
.seleradio {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 25rpx;
}
.fktxt {
  width: 100%;
  height: 250rpx;
  padding: 25rpx;
  font-size: 32rpx;
  border-radius: 15rpx;
  background-color: rgb(246,246,246);
}
.lxfs-input {
  width: 100%;
  height: 90rpx;
  padding-left: 20rpx;
  font-size: 32rpx;
  border-radius: 15rpx;
  background-color: rgb(246,246,246);
}
.fkbtn {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  background-color: #4193FE;
  border-radius: 40rpx;
  border: 0;
  color: #fff;
  margin-top: 80rpx;
  
}
</style>